using System;
using System.Drawing;
using System.Windows.Forms;


namespace Camalon.Drawing
{
	public delegate void ValueChangeEventHandler(object sender, ValueChangeEventArgs e);
	public delegate void ValueChangingEventHandler(object sender, ValueChangingEventArgs e);
	
	public class ValueChangeEventArgs: System.EventArgs
	{
		object _oldValue;
		object _newValue;

		public ValueChangeEventArgs( object oldValue, object newValue)
		{
			_oldValue = oldValue;
			_newValue = newValue;
		}

		public object NewValue
		{
			get{ return _newValue;}
		}

		internal void SetValues( object oldValue, object newValue )
		{
			_newValue = newValue;
			_oldValue = oldValue;
		}

		public object OldValue
		{
			get{ return _oldValue;}
		}

	}

//	public class PathBoundsChangedEventArgs:ValueChangeEventArgs
//	{
//		RectangleF _oldInvalidatingBounds;
//
//		public PathBoundsChangedEventArgs( RectangleF oldValue, RectangleF newValue, RectangleF oldInvalidatingBounds)
//			:base( oldValue, newValue )
//		{
//			_oldInvalidatingBounds = oldInvalidatingBounds;
//		}
//
//
//		public RectangleF NewBounds
//		{
//			get{ return (RectangleF)base.NewValue;}
//		}
//
//		public RectangleF OldBounds
//		{
//			get{ return (RectangleF) base.OldValue;}
//		}
//
//		public RectangleF OldInvalidatingBounds
//		{
//			get{ return _oldInvalidatingBounds;}
//		}
//
//	}
//
	


	public class ValueChangingEventArgs: ValueChangeEventArgs
	{

		public ValueChangingEventArgs( object oldValue, object newValue)
			:base(oldValue,newValue){}

		bool _cancel	= false;
		public bool Cancel
		{
			get{ return _cancel;}
			set{_cancel = value;}
		}

	}

	
	public delegate void ShapeCollectionEventHandler(object sender, ShapeCollectionEventArgs e);

	public class ShapeCollectionEventArgs: System.EventArgs
	{
		public enum CollectionAction
		{
			Insert,
			Remove,
			Set,
			Clear
		}

		int					_index		= -1;
		object				_oldValue	= null;
		object				_newValue	= null;
		CollectionAction	_action		= CollectionAction.Clear;

		/// <summary>
		/// Clear constructor
		/// </summary>
		public ShapeCollectionEventArgs()
		{

		}
		
		/// <summary>
		/// Insert/Remove Constructor
		/// </summary>
		/// <param name="index"></param>
		/// <param name="value"></param>
		/// <param name="removed"></param>
		public ShapeCollectionEventArgs(int index, object value, bool removed )
		{
			_index = index;

			
			if( removed ) 
			{
				_oldValue	= value;
				_action = CollectionAction.Remove;
			}
			else 
			{
				_newValue	= value;
				_action = CollectionAction.Insert;
			}
		}

		/// <summary>
		/// Set constructor
		/// </summary>
		/// <param name="index"></param>
		/// <param name="oldValue"></param>
		/// <param name="newValue"></param>
		public ShapeCollectionEventArgs(int index, object oldValue, object newValue)
		{
			_index		= index;
			_oldValue	= oldValue;
			_newValue	= newValue;
			_action		= CollectionAction.Set;
		}

		public object OldValue
		{
			get{ return _oldValue;}
		}

		public object NewValue
		{
			get{ return _newValue;}
		}

		public CollectionAction Action
		{
			get{ return _action;}
		}

		public int Index
		{
			get{ return _index;}
		}
	}

}
